package com.wantup.demo03xd.part06.atomic;

import java.util.concurrent.atomic.LongAccumulator;

/**
 * @author Zhaoluowei
 * @version 1.0
 * @date 2019/7/4 10:17
 */
public class Demo2 {


    public static void main(String[] args) {
        //方法的参数 一个输入的 一个上一次运算的值。
        LongAccumulator longAccumulator = new LongAccumulator((left, right) ->
                left > right ? left : right, 0L);

        longAccumulator.accumulate(3);
        System.out.println(longAccumulator.get());
        longAccumulator.accumulate(2);
        System.out.println(longAccumulator.get());
        longAccumulator.accumulate(10);
        System.out.println(longAccumulator.get());


    }
}
